package mws.metadataModel;

import cn.hutool.core.util.StrUtil;
import lombok.Builder;

import java.util.regex.Pattern;

@Builder
public class Description {

    private final Integer min;
    private final Integer max;
    private final String mark;
    private final String pattern; // 新增：正则表达式
    private final String example; // 新增：示例值



    public String getContent() {
        String desc = mark;
         if(StrUtil.isNotBlank(pattern)){
             boolean matches = Pattern.matches(pattern, mark);
             if(!matches){
                 desc = String.format("格式错误，正则表达式：%s，示例值：%s", pattern, example);
             }
         }
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.append("");
         if(min != null){
             stringBuilder.append(String.format("最小值：%d，%s", min));
         }
         if(max != null){
             stringBuilder.append(String.format("最大值：%d，%s", max));
         }
        return StrUtil.format("{}  {} ", stringBuilder.toString(), desc);
    }


}
